﻿/*
 * Copyright 2010-2013 Team Robot, Inc.
 * 
 * Author: Peter Coley
 */

using System;
using System.Collections.Generic;
using System.Linq;

namespace TeamRobot.Swtor
{
    /// <summary>
    /// Describes an item source (a single item can have multiple sources).  See ToString to understand how the different fields are used for the different SourceType values.
    /// This class should not be modified without notifying Team Robot; otherwise generated item sources may be incompatible with swtor.askmrrobot.com.
    /// </summary>
    public class ItemSource
    {
        public SourceType SourceType { get; set; }
        public string Zone { get; set; }
        public string Currency { get; set; }
        public string Cost { get; set; }
        public string Npc { get; set; }
        public Faction? Faction { get; set; }
        public ZoneDifficulty? Difficulty { get; set; }

        public override string ToString()
        {
            switch (this.SourceType)
            {
                case SourceType.Flashpoint:
                case SourceType.Operation:
                    return this.Zone + (!this.Difficulty.HasValue || this.Difficulty == ZoneDifficulty.Normal ? "" : "  (" + this.Difficulty.ToString() + ")") + (this.Npc == null || this.Npc == "" ? "" : " - " + this.Npc);
                case SourceType.WeaponVendor:
                    return this.Zone + " Weapon Vendor - " + this.Cost + " " + this.Currency;
                case SourceType.ArmorVendor:
                    return this.Zone + " Armor Vendor - " + this.Cost + " " + this.Currency;
                case SourceType.ModsVendor:
                    return this.Zone + " Mods Vendor - " + this.Cost + " " + this.Currency;
                case SourceType.StarshipUpgradeVendor:
                    return this.Zone + " Starship Upgrades Vendor - " + this.Cost + " " + this.Currency;
                case SourceType.GeologistVendor:
                    return this.Zone + " Geologist Vendor - " + this.Cost + " " + this.Currency;
                case SourceType.LegacyVendor:
                    return "Legacy Vendor - " + this.Cost + " " + this.Currency;
                case SourceType.SpecialtyVendor:
                    return this.Zone + " Specialty Vendor - " + this.Cost + " " + this.Currency;
                case SourceType.SocialVendor:
                    return this.Zone + " Social Vendor - " + this.Cost + " " + this.Currency;
                case SourceType.SecurityKeyVendor:
                    return "Security Key Vendor - " + this.Cost + " " + this.Currency;
                case SourceType.LightVendor:
                    return "Light Side Vendor - " + this.Cost + " " + this.Currency;
                case SourceType.DarkVendor:
                    return "Dark Side Vendor - " + this.Cost + " " + this.Currency;
                case SourceType.Vendor:
                    return "Vendor - " + this.Cost + " " + this.Currency;
                case SourceType.Commendation:
                    return this.Cost == null ? this.Currency : this.Cost + " " + this.Currency;
                case SourceType.Pvp:
                    return "PvP - " + (this.Cost == null ? "" : this.Cost + " ") + this.Currency;
                case SourceType.Crafted:
                    return "Crafted - " + this.Zone;
                case SourceType.Ripped:
                    return "Ripped - Removed from other Items";
                case SourceType.QuestReward:
                    return "Mission Reward" + (this.Zone == null ? "" : ": " + this.Zone + (this.Currency == null ? "" : " - " + this.Currency) + (this.Cost == null ? "" : " (" + this.Cost + ")"));
                case SourceType.Retired:
                    return "No longer obtainable";
                case SourceType.ConstructionKit:
                    return "Kit From: " + this.Zone + " - " + this.Cost + " " + this.Currency;
                case SourceType.WorldBoss:
                    return "World Boss (" + this.Zone + ") - " + this.Npc;
                case SourceType.WorldDrop:
                    return "World Drop" + (this.Zone == null ? "" : ": " + this.Zone);
                case SourceType.Trainer:
                    return "Trainer - " + this.Zone + " - " + this.Cost + " " + this.Currency;
                case SourceType.ReverseEngineer:
                    return "RE - " + this.Currency;
                default:
                    return "";
            }
        }
    }
}
